package de.koller.reason.gameGui.listener;

import de.koller.reason.gameGui.visual.BasicVisual;
import de.koller.reason.gui.component.button.ButtonEvent;
import de.koller.reason.gui.component.button.ButtonStatus;
import de.koller.reason.gui.component.button.IButtonListener;
import de.koller.reason.gui.component.button.RButton;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;

public class FullScreenListener implements IButtonListener {

	private boolean fullscreen = false;
	private final RButton button;

	public FullScreenListener( RButton button ) {
		this.button = button;
	}
	
	@Override
	public void eventOccured( ButtonEvent event ) {
		if( event.buttonStatus == ButtonStatus.MouseReleased ) {
			fullscreen = !fullscreen;
			try { 
				Display.setFullscreen( fullscreen );
				
				if( fullscreen ) {
					button.setVisual( BasicVisual.NoFullscreenButton.part );
				} else {
					button.setVisual( BasicVisual.FullscreenButton.part );
				}
					
			} catch( LWJGLException ex ) {
				ex.printStackTrace();
			}
		}
	}

	
	
}
